

#import "FAMMineGenderViewController.h"

@interface FAMMineGenderViewController ()
@property (weak, nonatomic) IBOutlet UIButton *FAMMaleButton;
@property (weak, nonatomic) IBOutlet UIButton *FAMFemaleButton;

@end

@implementation FAMMineGenderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.FAMFemaleButton.layer.borderColor = kBlackColor.CGColor;
    self.FAMFemaleButton.layer.borderWidth = 2;
    
}
- (IBAction)FAM_maleButtonClick:(UIButton *)sender {
    [self.FAMFemaleButton setSelected:NO];
    [sender setSelected:YES];
    sender.layer.borderColor = kBlackColor.CGColor;
    sender.layer.borderWidth = 2;
    self.FAMFemaleButton.layer.borderColor = kClearColor.CGColor;
    self.FAMFemaleButton.layer.borderWidth = 2;
}
- (IBAction)FAM_femaleButtonClick:(UIButton *)sender {
    [sender setSelected:YES];
    [self.FAMMaleButton setSelected:NO];
    sender.layer.borderColor = kBlackColor.CGColor;
    sender.layer.borderWidth = 2;
    self.FAMMaleButton.layer.borderColor = kClearColor.CGColor;
    self.FAMMaleButton.layer.borderWidth = 2;
}

- (IBAction)FAMSaveButtonClick:(UIButton *)sender {
    NSString *gender = @"1";
    if (self.FAMMaleButton.isSelected) {
        gender = @"1";
    }else{
        gender = @"2";
    }
    WeakSelf(self);
    [self showHudInKeyWindowWithHint:nil];
    [FAMHttpTool FAM_PutFoodmateUserdataWithParameters:[NSMutableDictionary dictionaryWithDictionary:@{@"data":@{@"gender":gender}}] success:^(FAMFoodmateUserdataModel * _Nonnull model, NSString * _Nonnull msg) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf hideHudKeyWindow];
            [FAMUserManger shareInstance].userModel.gender = gender;
            [weakSelf.navigationController popViewControllerAnimated:YES];
        });
    } failure:^(NSString * _Nonnull errorInfo) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf hideHudKeyWindow];
            [weakSelf showHint:errorInfo];
        });
    }];
}


@end
